from sqlmodel import Field, SQLModel
from datetime import datetime
from sqlalchemy.dialects.mysql import JSON
from sqlalchemy import Column
from sqlalchemy import func, DateTime

class Word(SQLModel, table=True, ):
    __tablename__ = 'words' 

    id: int|None = Field(primary_key=True, default=None)
    spell: str = Field(default='', max_length=30)
    spell_split: str = Field(default='', max_length=35)
    phonetic_symbol: str = Field(default='', max_length=30)
    pic: str = Field(default='', max_length=255)
    is_deleted: int = Field(default=0)
    create_time: datetime = Field(default_factory=func.now)
    update_time: datetime = Field(sa_column=Column( DateTime, onupdate=func.now()), default_factory=func.now)
    meanings: dict= Field(default={}, sa_column=Column(JSON))